﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dracham.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;

namespace Dracham.Components.GameScreens
{
    public class TestScreen : IGameScreen
    {
        Texture2D texture;

        private Texture2D hudTop, hudBottom, fort;

        public TestScreen()
        {
            this.texture = Dracham.Instance.Content.Load<Texture2D>("GRS2ROC");

            this.hudTop = Dracham.Instance.Content.Load<Texture2D>(@"Graphics\Interface\1024x768\top");
            this.hudBottom = Dracham.Instance.Content.Load<Texture2D>(@"Graphics\Interface\1024x768\bottom");
            this.fort = Dracham.Instance.Content.Load<Texture2D>("w2fort");
        }

        #region IGameScreen Members

        public void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = Dracham.Instance.SpriteBatch;

            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);

            int x = (int)Math.Round(((double)Dracham.Instance.GraphicsDevice.Viewport.Width) / 40d, 0, MidpointRounding.AwayFromZero);
            int y = (int)Math.Round(((double)Dracham.Instance.GraphicsDevice.Viewport.Height) / 40d, 0, MidpointRounding.AwayFromZero);

            for (int a = 0; a < x; a++)
            {
                for (int b = 0; b < y; b++)
                {
                    spriteBatch.Draw(texture, new Rectangle(a*40, b*40, 40, 40), new Rectangle(280, 81, 40, 40), Color.White);
                }
            }

            spriteBatch.Draw(this.fort, new Rectangle(512, 500, 100, 100), Color.White);

            spriteBatch.Draw(this.hudTop, Vector2.Zero, Color.White);
            spriteBatch.Draw(this.hudBottom, new Vector2(0, 623), Color.White);

            spriteBatch.End();            
        }

        public bool Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape)) return true;

            

            return false;
        }

        #endregion
    }
}
